﻿
        function listMessages(callback) {
            $.ajax({
                url: "/api/Message2/GetAllMessages/"+"@Model.chat.Id",
                data: {},
                type: "GET",
                contentType: "application/json;charset=utf-8",
            }).then(function(messages){
                callback(messages);
            });
    }

    function count()
      {
         parent = document.getElementById("messages");
         kids = parent.childNodes.length;
         
         return kids;
      }

      function addMessage(callback)
      {
        $.ajax({
            url: "/api/Message2/GetMessage/"+"@Model.chat.Id",
            data: {count: count()},
            type: "GET",
            contentType: "application/json;charset=utf-8",
            }).then(function(mess){
                callback(mess);
            });

      }
      
      function getCount()
      {
          $.get(
            "/api/Message2/GetCount/"+"@Model.chat.Id",
            {},
            function(response)
            {
                return response;
            }
            );
      }

